/*********************************************************
 *
 * Filename: demo/read_bmp_fromfile.c
 *   Author: jmdvirus
 *   Create: 2019年04月24日 星期三 17时23分46秒
 *
 *********************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include "cm_bmp_file3.h"

#define LOGD(fmt, ...)                                                         \
    do                                                                         \
    {                                                                          \
        printf(fmt, ##__VA_ARGS__);                                            \
    } while (0)

int main(int argc, char **args)
{
    if (argc < 2)
    {
        LOGD("Usage: %s bmpfile\n", args[0]);
        exit(0);
    }

    const char *bmpfile = args[1];

    FILE *fo = fopen(bmpfile, "w");

    if (fo)
    {
        int n = fwrite(cm_logo_bmp, 1, sizeof(cm_logo_bmp), fo);
        LOGD("write bmp file [%d], real [%lu]\n", n, sizeof(cm_logo_bmp));

        fclose(fo);
    }

    return 0;
}
